from bs4 import BeautifulSoup
import requests

from getPages import scrape_infinite_scroll_api

print("222")
# 使用 requests 获取网页内容
url = 'https://movie.douban.com' # 抓取bing搜索引擎的网页内容
urlPage='https://movie.douban.com/j/chart/top_list'
head={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36'}
response = requests.get(url,headers=head)
# 中文乱码问题
response.encoding = 'utf-8'
# 使用 BeautifulSoup 解析网页
#soup = BeautifulSoup(response.text, 'lxml')  # 使用 lxml 解析器
# 确保请求成功
# if response.status_code == 200:
#     # 使用BeautifulSoup解析网页内容
#     soup = BeautifulSoup(response.text, 'lxml')
#
#
#     # 查找<title>标签
#     title_tag = soup.find('title')
#
#     # 打印标题文本
#     if title_tag:
#         print(title_tag.get_text())
#     else:
#         print("未找到<title>标签")
#     movieList = soup.find_all('li',class_='ui-slide-item')
#     for item in movieList:
#         list_title=item.find('li',class_='title').find('a').get_text()
#         score=item.find('span',class_='subject-rate')
#         scoreStr='--'
#         if score:
#             scoreStr=score.get_text()
#         else:
#             scoreStr=item.find('span',class_='text-tip').get_text()
#
#         print(list_title+"-----"+scoreStr)
# else:
#     print("请求失败，状态码：", response.status_code)
list=scrape_infinite_scroll_api(urlPage,head)




